home *** CD-ROM | disk | FTP | other *** search
- Path: jaring.my!n16872!ckyin
- From: ckyin@n16872.pc.jaring.my (Yin Chee Kin)
- Newsgroups: comp.lang.c
- Subject: Re: Beginer C please help me
- Message-ID: <827821769.0snx@n16872.pc.jaring.my>
- References: <4irjqa$jtn@winx03.informatik.uni-wuerzburg.de>
- Date: Tue, 26 Mar 96 06:29:29 GMT
- Organization: Pantai Dalam
-
- In article <4irjqa$jtn@winx03.informatik.uni-wuerzburg.de> schoof@informatik.uni-wuerzburg.de writes:
- >
- >Scott Shrader (shrader@scsn.net) wrote:
- >: In article <DoLCFx.B7x.0.bloor@torfree.net>, bz786@torfree.net says...
- >: >
- >: >This may be a stupid mistake but "please help" me.
- >: >Thank you very much.
- >: >
- >: >#include <stdio.h>
- >: >#include <math.h>
- >: >main ()
- >: >{
- >: >float n;
- >: >n=(9/5);
- >: >printf ("n= %1.3f\n", n);
- >: >}
- >: >I have complied and run the programme & I got the answer n=1.000
- >: >but Iam supposed to get answer 1.8.
- >: >Why I got this answer?
- >: >--
- >: you can write this by skipping printf("n= %1.3f\n", n); and put in
- >: printf("%f",n);
- >:
- >: Try this to see how this works.
- >
- >What you wrote is complete nonsense. How about testing the programs
- >before posting them..? Even learning C might be of help.
- >
- >: I'm a bit new at this too, but I think this will work.
- >
- >If you have to use phrases like "I think it will work" or "I'm not sure"
- >in your posting, please don't post it. There are enough folks around
- >here who know for sure - especially in elementary cases like this one.
- >
- >- Jochen
- >
- >--
- >--------------------------------------------------------------------------
- > Jochen Schoof mailto:schoof@informatik.uni-wuerzburg.de
- > Lehrstuhl fuer Informatik II +-------------------------------------------
- > Universitaet Wuerzburg | You are just reading a .sig-light:
- > D-97074 Wuerzburg (Germany) | It is free of fat, sugar and cholesterol!
- >------------------------------+-------------------------------------------
- > WWW-Homepage: http://www.informatik.uni-wuerzburg.de/staff/joscho
- >--------------------------------------------------------------------------
- >
-
- Jochen,
-
- I agree with you completely. What a complete nonsense!
-
- In order a get correct answer, should try this:
-
- n = 9.0/5 or n = 9/5.0 or n = 9/5*1.0
-
- Remember, in C you may not get a floating point answer by division
- using integer only!
-
- I hope this will help!
-
-
-
-
-